package com.supreme.stockserver.controller;

import com.supreme.common.entity.ProductQuality;
import com.supreme.commonentity.mysql.primary.BizProduct;
import com.supreme.commonboot.utils.AjaxResp;
import com.supreme.stockserver.service.ProductService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(value = "product")
public class ProductController {

    @Resource
    private ProductService productService;

    @PostMapping(value = "createProduct")
    public AjaxResp createProductQuality(@RequestBody BizProduct product) {
        final int result = productService.createProduct(product);
        return AjaxResp.instance(result);
    }

    @PostMapping(value = "createProductQuality")
    public AjaxResp createProductQuality(@RequestBody ProductQuality productQuality) {
        /*try {
            productService.createProductQuality(productQuality);
        } catch (RuntimeException e) {
            System.out.println(e.getMessage());
        }*/
        productService.createProductQuality(productQuality);
        return AjaxResp.instance();
    }
}
